// This source is subject to the Microsoft Public License.
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
// All other rights reserved.

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Reflection;
using System.Windows.Forms;

namespace QuoteAdvantageEditor
{
	/// <summary>
	/// Summary description for AboutDlg.
	/// </summary>
	public class AboutDlg : System.Windows.Forms.Form
	{
      private System.Windows.Forms.Button btnOK;
      private System.Windows.Forms.Label label1;
      private System.Windows.Forms.Label label4;
      private System.Windows.Forms.PictureBox pictureBox1;
      private System.Windows.Forms.Label label2;
      private System.Windows.Forms.Label lblVersion;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public AboutDlg()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
         System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(AboutDlg));
         this.btnOK = new System.Windows.Forms.Button();
         this.label1 = new System.Windows.Forms.Label();
         this.lblVersion = new System.Windows.Forms.Label();
         this.label4 = new System.Windows.Forms.Label();
         this.pictureBox1 = new System.Windows.Forms.PictureBox();
         this.label2 = new System.Windows.Forms.Label();
         this.SuspendLayout();
         // 
         // btnOK
         // 
         this.btnOK.Location = new System.Drawing.Point(256, 160);
         this.btnOK.Name = "btnOK";
         this.btnOK.Size = new System.Drawing.Size(96, 23);
         this.btnOK.TabIndex = 0;
         this.btnOK.Text = "OK";
         this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
         // 
         // label1
         // 
         this.label1.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
         this.label1.Location = new System.Drawing.Point(64, 16);
         this.label1.Name = "label1";
         this.label1.Size = new System.Drawing.Size(208, 16);
         this.label1.TabIndex = 1;
         this.label1.Text = "QuoteAdvantage 2008 Editor";
         // 
         // lblVersion
         // 
         this.lblVersion.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
         this.lblVersion.Location = new System.Drawing.Point(64, 72);
         this.lblVersion.Name = "lblVersion";
         this.lblVersion.Size = new System.Drawing.Size(176, 16);
         this.lblVersion.TabIndex = 3;
         this.lblVersion.Text = "Version AA.BB";
         // 
         // label4
         // 
         this.label4.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
         this.label4.Location = new System.Drawing.Point(64, 96);
         this.label4.Name = "label4";
         this.label4.Size = new System.Drawing.Size(192, 32);
         this.label4.TabIndex = 4;
         this.label4.Text = "Distributed under the terms of the Microsoft Public License (Ms-PL)";
         // 
         // pictureBox1
         // 
         this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
         this.pictureBox1.Location = new System.Drawing.Point(8, 8);
         this.pictureBox1.Name = "pictureBox1";
         this.pictureBox1.Size = new System.Drawing.Size(48, 50);
         this.pictureBox1.TabIndex = 5;
         this.pictureBox1.TabStop = false;
         // 
         // label2
         // 
         this.label2.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
         this.label2.Location = new System.Drawing.Point(64, 136);
         this.label2.Name = "label2";
         this.label2.Size = new System.Drawing.Size(144, 16);
         this.label2.TabIndex = 6;
         this.label2.Text = "All Rights Reserved.";
         // 
         // AboutDlg
         // 
         this.AcceptButton = this.btnOK;
         this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
         this.ClientSize = new System.Drawing.Size(362, 192);
         this.Controls.Add(this.label2);
         this.Controls.Add(this.pictureBox1);
         this.Controls.Add(this.label4);
         this.Controls.Add(this.lblVersion);
         this.Controls.Add(this.label1);
         this.Controls.Add(this.btnOK);
         this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
         this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
         this.MaximizeBox = false;
         this.MinimizeBox = false;
         this.Name = "AboutDlg";
         this.ShowInTaskbar = false;
         this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
         this.Text = "About QuoteAdvantage Editor";
         this.Load += new System.EventHandler(this.AboutDlg_Load);
         this.ResumeLayout(false);

      }
		#endregion
      
      private void AboutDlg_Load(object sender, System.EventArgs e)
      {
         string strVersionNumber = FindVersion("QuoteAdvantageEditor"); 
         lblVersion.Text = "Version " + strVersionNumber;
      }

      private void btnOK_Click(object sender, System.EventArgs e)
      {
         this.Close();
      }

 
      private string FindVersion(string strAssemblyName)
      {
         string      strResult;
         Assembly    objAssembly = null;

         try
         {
            objAssembly = Assembly.Load(strAssemblyName);
            strResult = objAssembly.GetName().Version.ToString();
         }
         catch (Exception)
         {
            strResult = "Warning - Missing Assembly";
         }

         return strResult;
      }

	} // end class
}
